package com.wzg.jetpack_blackbox.login.room;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao()
public interface IUserDao {

    @Query("SELECT * FROM user_table")
    List<User> getAll();


    @Delete(entity = User.class)
    int deleteUser(User user);

    @Query("SELECT * FROM user_table WHERE userId=:userId")
    User queryByUserId(String userId);

    //存在则替换
    @Insert(entity = User.class, onConflict = OnConflictStrategy.REPLACE)
    void insertUser(User... user);

    @Update(entity = User.class)
    void update(User user);
}
